<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/jian-sheng-zi-lcof/
      思路：https://leetcode-cn.com/problems/jian-sheng-zi-lcof/solution/shuang-jie-fa-dong-tai-gui-hua-tan-xin-fa-fu-zha-2/
     */
    function cuttingRope(n) {
      if (n === 2)  return 1;
      if (n === 3)  return 2;

      let a = n / 3 | 0;
      let b = n % 3;

      if (b === 0)  return Math.pow(3, a);
      if (b === 1)  return Math.pow(3, a-1) * 4;
      if (b === 2)  return Math.pow(3, a) * 2;
    }
  </script>
</body>
</html>